<template>
  <div
    class="remark"
    v-show="isShowRemark"
  >
  <div class="parter">
    <div class="first">
      <img
        src="../assets/backicon.svg"
        class="iconaa"
        @click.stop="$emit('stop-remark', isShowRemark)"
      />
      <span class="pinlun">评论({{ Discuss.length }})</span>
    </div>
    </div>
    <div class="two">
      <div class="left"><img :src="picUrl" alt="" /></div>
      <div class="right">
        <p class="songName">{{ currentMusic.name }}</p>
        <span class="Man">{{ manName }}</span>
      </div>
    </div>
    <div class="list">按推荐排序</div>
    <ul @touchstart="touchstart"
    @touchmove="touchmove"
    @touchend="touchend">
    <div class="three" v-for="(remark, index) in Discuss" :key="index">
      <div class="topAll">
        <img :src="remark.user.avatarUrl" class="leftImg" />
        <div class="top">
          <div class="name">{{ remark.user.nickname }}</div>
          <p class="time">{{ remark.time | moment }}</p>
        </div>
        <div class="zhangbox">
          <span class="namber">{{ remark.likedCount }}</span>
          <img src="../assets/dianzhang.svg" alt="" class="zhang" />
        </div>
      </div>
      <div class="pinglun">{{ remark.content }}</div>
    </div>
    <div class="toomuch" @click="getMore">加载更多...</div>
    </ul>
  </div>
</template>

<script>
export default {
  props: ["isShowRemark", "picUrl", "currentMusic"],
  data() {
    return {
      limit:20,
      Discuss: "",
      currentRow: 0,
      scorllY: 0,
    };
  },
  computed: {
    manName: function () {
      let manName;
      if (this.currentMusic.ar) {
        manName = this.currentMusic.ar[0].name;
      }
      if (this.currentMusic.song) {
        manName = this.currentMusic.song.artists[0].name;
      }
      if (this.currentMusic.artists) {
        manName = this.currentMusic.artists[0].name;
      }
      return manName;
    },
  },
  created() {
    this.getData();
  },
  methods: {
    getData: function () {
      this.$root.isShowLoading = true;
      this.axios
        .get("/comment/music?id=" + this.$route.query.id+"&limit="+this.limit)
        .then((response) => {
          this.Discuss = response.data.comments;
        })
        .finally(() => {
          this.$root.isShowLoading = false;
        });
    },
    touchstart: function (e) {
      // console.log('touchstart',e.touches[0].clientY);
      this.touching = true;
      this.y = e.touches[0].clientY;
    },
    touchmove: function (e) {
      // console.log('touchmove',e.touches[0].clientY);
      // console.log(Math.floor((this.y - e.touches[0].clientY) / 30));
      this.scorllY = Math.floor((this.y - e.touches[0].clientY) / 30);
    },
    touchend: function () {
      this.touching = false;
    },
    getMore() {
    this.limit+=20;
    this.getData()
}
  },
  watch: {
    $route: function () {
      this.getData();
    },
  },
};
</script>

<style scoped lang="less">
.remark {
  width: 100vw;
  height: 100vh;
  position: relative;
  background: url("../assets/pinglunbac.jpg") center;
  background-size: 100vw 100vh;
  overflow-y: scroll;
  overflow-x: hidden;
  font-size: 18px;
  top: 0;
  left: 0;
  z-index: 50;
  .parter{
    width: 100vw;
    height: 30px;
  .first {
    width: 100vw;
    height: 30px;
    margin-left: 10px;
    line-height: 30px;
    position: fixed;
    background-color: #2a385d;
    z-index: 10;
    top: 0;
    left: 0;
    .iconaa {
      width: 25px;
      height: 25px;
      margin-top: -8px;
    }
    .pinlun {
      margin-left: 50px;
      color: white;
      font-weight: 600;
    }
  }
  }
  .two {
    width: 100vw;
    height: 100px;
    margin-top: 60px;
    .left {
      width: 25vw;
      height: 100px;
      margin-left: 20px;
      img {
        width: 25vw;
        height: 100px;
        border-radius: 5px;
      }
    }
    .right {
      width: 65vw;
      height: 100px;
      margin-left: 35vw;
      margin-top: -99px;
      .songName {
        width: 100%;
        height: 30px;
        line-height: 30px;
        font-size: 16px;
        margin-top: 105px;
        margin-left: 70px;
      }
      .Man {
        display: inline-block;
        width: 100%;
        height: 30px;
        line-height: 40px;
        font-size: 14px;
        margin-top: 40px;
        color: #8bb8dd;
      }
    }
  }
  .list {
    width: 100vw;
    height: 30px;
    margin-top: 15px;
    font-weight: 400;
    color: white;
    font-size: 15;
  }
  .three {
    width: 100%;
    margin-top: 10px;
    height: 130px;
    .topAll {
      width: 100%;
      height: 50px;
      .leftImg {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        margin-left: 20px;
      }
      .top {
        width: 50%;
        height: 100%;
        margin-left: 100px;
        display: inline-block;
        margin-left: 0;
        margin-top: -54px;
        .name {
          width: 100%;
          height: 20px;
          line-height: 20px;
          display: -webkit-box;
          color: white;
          font-size: 15;
          text-overflow: -o-ellipsis-lastline;
          overflow: hidden;
          text-overflow: ellipsis;
          -webkit-line-clamp: 1;
          line-clamp: 1;
          -webkit-box-orient: vertical;
        }
        .time {
          width: 146px;
          height: 20px;
          line-height: 20px;
          display: inline-block;
          margin-left: 0;
          margin-top: 10px;
          color: #8bb8dd;
        }
      }
      .zhangbox {
        display: inline-block;
        width: 20%;
        height: 100%;
        margin-left: 30px;
        margin-top: 0;
        .namber {
          height: 20px;
          color: white;
          font-size: 13px;
          display: inline-block;
        }
        .zhang {
          width: 25px;
          height: 25px;
          padding-top: 5px;
        }
      }
    }
    .pinglun {
      width: 80%;
      height: 68px;
      color: white;
      margin-top: 10px;
      font-size: 13px;
      margin-left: 20%;
      text-overflow: -o-ellipsis-lastline;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 4;
      line-clamp: 4;
      -webkit-box-orient: vertical;
    }
  }
  .toomuch{
    width: 100vw;
    height: 30px;
    font-size: 16px;
    color: #8bb8dd;
    text-align: center;
    line-height: 30px;
  }
}
</style>